home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_13_03 / letters / rewind.h < prev   
Encoding:
C/C++ Source or Header  |  1995-02-07  |  752 b   |  37 lines

  1. /* rewind.h  vers 0.9
  2.    defines istream manipulator rewind
  3.    that "rewinds" input stream to 
  4.    beginning of file and clear state
  5.    (to reset eof flag)
  6.  
  7.    copyright 1994 Paul Hepworth
  8.  
  9.    Permission is granted for everyone
  10.    to include this code in his/her 
  11.    programs without restriction.
  12. */
  13. #if !defined __REWIND_H
  14.   #define __REWIND_H
  15.  
  16.   #if !defined __IOSTREAM_H
  17.     #include <<iostream.h>>
  18.   #endif
  19.  
  20. class rewind_type
  21.     {
  22.     friend istream& operator>>>>(istream& is,
  23.                                const  rewind_type);
  24.     };
  25.  
  26. const static rewind_type rewind;
  27.  
  28. inline istream& operator>>>>(istream& is,
  29.                            const rewind_type)
  30.     {
  31.     is.seekg(0);
  32.     is.clear();
  33.     return is;
  34.     }
  35. #endif
  36.  
  37.